<%-- 
    Document   : AddVip_test
    Created on : 2014/2/27, 下午 02:15:20
    Author     : Gjun
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%  
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    java.sql.Connection con = java.sql.DriverManager.getConnection(
        "jdbc:sqlserver://10.10.2.171:1433;databaseName=javadb", "javadb", "javadb");
    String sql="select * from account_test_only";  //在公務上千萬不要用*!!!乖乖打欄位 !!!切記!!!
    java.sql.Statement st = con.createStatement();
    java.sql.ResultSet rs =st.executeQuery(sql);
    
%>
<html>
    <head>
        <title>加入會員</title>        
    
        <script src="jquery-1.10.2.js"></script>
        <script type="text/javascript">

            var addressXml;

            $(document).ready(function () {

                addressXml = $.get("Address.xml", null, LoadCounty, "xml");
                $("#form1").submit(CheckForm);
                $("#county").change(LoadRegion);

            });

            //載入縣市
            function LoadCounty(xx) {
                addressXml = xx;
                var s = "";
                var vv = "";
                $(addressXml).find("County").each(function () {
                    vv = $(this).attr("Name");
                    s = "<option value=\"" + vv + "\">" + vv + "</option>";
                    $(s).appendTo("#county");
                });
            }

            //載入鄉鎮
            function LoadRegion() {
                var s = "";
                var uu = "";
                $("#region").empty();
                uu = "<option>--請選擇--</option>";
                $(uu).appendTo("#region");

                var vv = $("#county").val();
                if (vv == "--請選擇--") return;
                $(addressXml).find("County[Name=\"" + vv + "\"]").first().children().each(function () {
                    uu = $(this).attr("Name");
                    s = "<option value=\"" + uu + "\">" + uu + "</option>";
                    $(s).appendTo("#region");
                });
            }

            //檢驗表單
            function CheckForm() {
                var msg = "";

                var vv = document.getElementById("accountName").value;
                if (vv == "") msg += "* 帳號必須填寫！\n";

                var vv = document.getElementById("accountPassword").value;
                if (vv == "") msg += "* 密碼必須填寫！\n";

                var vv = document.getElementById("birth").value;
                var reg = /^\d{4}([./-])[01]?\d\1[0-3]?\d$/;
                if (vv == "")
                    msg += "* 生日必須填寫！\n";
                else if (!reg.test(vv))
                    msg += "* 生日格式不正確！\n";

                if (msg != "") {
                    alert(msg);
                    return false;
                }
            }

        function reload(){
            document.getElementById("picture").src="Captcha";           
        }        
   
            </script>
             <style>
            .new_loginbutton{
                font-size:1em;
                cursor:pointer;
                border:1px outset #ccc;
                color:#000;
                font-weight:normal;
                margin:2px 0;}
            
            #loginbox{
                width:250px;
                text-align:left;
                padding:0 4px;
                margin:0 auto;
}

            #idiot { float: left;
                     margin-top:300px;}
        </style>
    </head>
    <body>
        <h2>填寫會員資料</h2>
         <form id="form1" action="<%= response.encodeURL("AddVipOk.jsp") %>" method="post">
             <table width="950" cellpadding="15" BORDER="2">
                <tr>
                    <td align="right" width="100"><b>帳號：</b></td>
                    <td width="250"><input id="login_account" name="login_account" type="text" value="" /></td>
                </tr>
                <tr>
                    <td align="right" width="100"><b>生日：</b></td>
                     <td><select id="birth_year" name="birth_year">
                     <option>--請選擇--</option>
                         <%
                              for(int k=1;k<=114;k++)
                                 {                                          
                         %>                                          
                    <option value="<%=1900+k%>"><%=1900+k%></option> 
                <%}%>  
                </select>年<br>
              
               <select id="birth_month" name="birth_month">
                    <option>--請選擇--</option>
                     <%
                    for(int j=1;j<=12;j++)
                    {                                          
                %>  
                    <option value="<%=j%>"><%=j%></option> 
                <%}%>          
                </select>月<br>
           
                
              <select id="birth_day" name="birth_day">
                    <option>--請選擇--</option>
                <%
                    for(int i=0;i<=30;i++)
                    {                                          
                %>  
                    <option value="<%=i+1%>"><%=i+1%></option> 
                <%}%>            
                </select>日
                </td>
                            
            
                </tr>
                <tr>
                    <td align="right"><b>密碼：</b></td>
                    <td><input id="login_password" name="login_password" type="password" value="" /></td>
                </tr>
                <tr>
                    <td align="right"><b>確認密碼：</b></td>
                    <td><input id="confirmAccountPassword" type="password" value="" /></td>
                    <td align="right" valign="middle"><b>聯絡地址：</b></td>
                    <td rowspan="2">
                        <p><b>縣市：</b><select id="county" name="county"><option>--請選擇--</option></select>&nbsp;&nbsp;
                            <b>鄉鎮市：</b><select id="region" name="region"><option>--請選擇--</option></select></p>
                        <p><b>地址：</b><input id="address" name="address" type="text" value="" /></p></td>
                </tr>
                <tr>
                    <td align="right"><b>姓名：</b></td>
                    <td><input id="user_name" name="user_name" type="text" value="" /></td>
                    <td align="right"><b></b></td>
                </tr>
                <tr>
                    <td align="right"><b>性別：</b></td>
                    <td><input id="maleSex" name="sex" type="radio" value="男生" />男生 <input id="femaleSex" name="sex" type="radio" value="女生" />女生</td>
                    <td align="right" valign="middle">
                    驗證碼:<img src="Captcha" id="picture">
                        <input type="button" value="挖看謀" onclick="reload()">
                        <br>
                        <input type="text" name="captcha" >
                    
                    </td>
                </tr>
                <tr>
                    <td align="right"><b>電子郵件：</b></td>
                    <td colspan="2"><input id="email" name="email" type="text" value="" /></td>
                    <td align="right">&nbsp;</td>
                </tr>
                <tr>
                    <td align="right">&nbsp;</td>
                    <td>
                        <input id="Submit1" type="submit" value="加入會員" />
                        <input id="Reset1" type="reset" value="重新填寫" /></td>
                    <td align="right">&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
            </table>
        </form>
    </body>
</html>

